<?php

/* platform base directory */
$dir_platform_code = realpath( dirname( dirname( __FILE__ ) ) );
/* platform library directory */
$dir_platform_lib = $dir_platform_code . DIRECTORY_SEPARATOR . "Platform" . DIRECTORY_SEPARATOR . "Library";
/* application library directory */
$dir_application_lib = $dir_platform_code . DIRECTORY_SEPARATOR . "Application" . DIRECTORY_SEPARATOR . "Library";
/* search both the base code directory and the library path */
$path = implode( PATH_SEPARATOR, array( $dir_platform_code, $dir_platform_lib, $dir_application_lib ) );
set_include_path( $path );

/* automatic class loader */
function __autoload( $name ){
	$path_array = explode( PATH_SEPARATOR, get_include_path() );
	foreach ( $path_array as $path ) {
		/* replace _ with DS and append .php */
		$file =  $path . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $name) . ".php";
		/* if it exists then require it */
		if( file_exists( $file ) ){
			error_log( substr( "Platnik Loading " . $name . ' from ' . $file, 0, 1024) );
			require( $file );
			return true;
		}
		else {
			error_log( substr( "Platnik Failed Loading " . $name . ' from ' . $file, 0, 1024) );
		}
	}
	error_log( "Platnik Failed Loading Class " . $name );
	return false;
}


class Platform_Factory extends Platform_Factory_Abstract
{
	
}

